home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Disc to the Future 2
/
Disc to the Future Part II Programmer's Reference (Wayzata Technology)(6013)(1992).bin
/
MAC
/
THINKC
/
4_0
/
LIFE_SIM
/
VERSION_
/
INITFROM.C
< prev
next >
Wrap
Text File
|
1992-03-12
|
2KB
|
95 lines
/* Cell Proj 1.0 */
#include "MacProto.h"
#include "Cell_Proto.h"
#include "Cell_Definitions.h"
#include "Cell_Variables.h"
ToolBoxInit()
{
InitGraf( &thePort );
GetDateTime( &randSeed );
InitFonts();
FlushEvents( everyEvent, REMOVE_ALL_EVENTS );
InitWindows();
InitMenus();
TEInit();
InitDialogs( NIL_POINTER );
InitCursor();
}
WindowInit()
{
gCellWindow = GetNewWindow( BASE_RES_ID, NIL_POINTER, MOVE_TO_BACK );
gSizeRect.top = MIN_WINDOW_HEIGHT;
gSizeRect.left = MIN_WINDOW_WIDTH;
gSizeRect.bottom = screenBits.bounds.bottom - screenBits.bounds.top;
gSizeRect.right = screenBits.bounds.right - screenBits.bounds.left;
SetPort( gCellWindow );
SetOrigin( -5, -5 );
}
DialogInit()
{
gCellInfoDialog = GetNewDialog( BASE_RES_ID, NIL_POINTER,
( WindowPtr ) MOVE_TO_FRONT );
ShowWindow( gCellInfoDialog );
}
MenuBarInit()
{
Handle myMenuBar;
myMenuBar = GetNewMBar( BASE_RES_ID );
SetMenuBar( myMenuBar );
gAppleMenu = GetMHandle( APPLE_MENU_ID );
gFileMenu = GetMHandle( FILE_MENU_ID );
AddResMenu( gAppleMenu, 'DRVR' );
DrawMenuBar();
}
SetUpDragRect()
{
gDragRect = screenBits.bounds;
gDragRect.left += DRAG_THRESHOLD;
gDragRect.right -= DRAG_THRESHOLD;
gDragRect.bottom -= DRAG_THRESHOLD;
}
DisplayCellWindow()
{
ShowWindow( gCellWindow );
DrawControls( gCellWindow );
}
PlaceRandomCells()
{
int randomLiveCell;
int count;
for ( count = 0; count < NUMBER_OF_CELLS; count++ )
{
gCellStatus[count] = 0;
}
for ( count = 0; count < 800; count++ )
{
randomLiveCell = Randomize( 9999 );
gCellStatus[randomLiveCell] = 1;
GraphAlive( randomLiveCell );
}
}
Randomize( range )
int range;
{
long rawResult;
rawResult = Random();
if ( rawResult < 0 )
rawResult *= -1;
return((( rawResult * ( range )) / 32768 ) + 1 );
}